<?php
namespace app\adminweb\controller;
use think\Controller;
header("Access-Control-Allow-Origin: * ");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
Class Uplode extends Controller
{
    //uEditor上传图片
    public function index(){
        // 获取表单上传文件 例如上传了001.jpg
        $file = request()->file('file');
        // 移动到框架应用根目录/uploads/ 目录下
        $info = $file->rule('uniqid')->move(ROOT_PATH . 'public' . DS . 'static/upload');
        if($info){
            // 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
            $name = $info->getSaveName();
            // 输出 42a79759f284b767dfcb2a0197904287.jpg
            $name1 = $info->getFilename();
            $arr = array('src'=>"https://show.enterlo.com/public/static/upload/$name",'title'=>"$name1");
            $array = array('code'=>0,'msg' =>'','data'=>$arr);
            return $array;
        }else{
            // 上传失败获取错误信息
            $array = array('code'=>0,'msg' =>'','data'=>0);
        }
    }
}
